<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p>
	<?php 
		echo $this->Html->link(
			$this->Html->image('fb_share_btn.jpg', array('width' => '40')),
			'javascript:void(0)',
			array('escape' => false, 'onclick' => 'postToFeed(); return false;')
		)
	?>
</p>
<p id='msg'></p>

<?php echo $this->Html->scriptStart(array('inline' => false)) ?>
	FB.init({appId: "<?php echo FB_APP_KEY ?>", status: true, cookie: true});
	
	function postToFeed() {
	
	var obj = {
	method: 'feed',
		link: 'https://developers.facebook.com/docs/reference/dialogs/',
		picture: 'http://d2518cupm1fmeh.cloudfront.net/7d548fe9-6562-44fa-adb9-1cd56476989a_thumb.jpg',
		name: '<?php echo isset($fb_share_name) ? $fb_share_name : 'Meshtiles' ?>',
		caption: '<?php echo isset($fb_share_caption) ? $fb_share_caption : $this->Html->url( null, true ); ?>',
		description: '<?php echo isset($fb_share_description) ? $fb_share_description : 'I have just sharing something from Meshtiles'; ?>'
	};
	
	function callback(response) {
		if (response) {
			document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
		}
	}
	
	FB.ui(obj, callback);
	}
<?php echo $this->Html->scriptEnd() ?>
